package dfs;

import java.util.LinkedList;

public class 拆分字符串使唯一子字符串数目最大 {

    public int maxUniqueSplit(String s) {
        if (s==null || s.length()==0)
            return 0;
        LinkedList<String> list = new LinkedList<>();
        dfs(s,list,0);
        System.out.println(list.size());
        return max;
    }
    int max=1;
    private void dfs(String s, LinkedList<String> list,int index) {
        if (index==s.length()){
            max=Math.max(max,list.size());
            return;
        }
        for (int i = index+1; i <= s.length(); i++) {
            String s1 = s.substring(index, i);
            if (list.contains(s1))
                continue;
            list.add(s1);
            dfs(s,list,i);
            list.remove(list.size()-1);
        }
    }
}
